package cn.cstech.aijia.model;

import com.baidu.nplatform.comapi.map.gesture.Base;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created with Android Studio.
 * Title:AdType
 * Description:
 * Copyright:Copyright (c) 2014
 * Company:中国平安健康保险有限公司
 * Author:Alice
 * Date:15/9/2
 * Time:下午4:15
 * Version 1.0
 */
public class AdType extends BaseDataHeader implements Serializable{
    private static final long serialVersionUID = 7653748709269743717L;
    //广告描述
    public String des;
    //广告链接
    public String link;
    //广告图片
    public String icon;

    public static AdType deserialize(String json) throws JSONException {
        if (json != null && !json.isEmpty()) {
            return deserialize(new JSONObject(json));
        }
        return null;
    }

    public static AdType deserialize(JSONObject json) throws JSONException {
        if (json != null && json != JSONObject.NULL && json.length() > 0) {
            AdType result = new AdType();

            if (!json.isNull("des")) {
                result.des = json.optString("des", null);
            }

            if (!json.isNull("link")) {
                result.link = json.optString("link", null);
            }

            if (!json.isNull("icon")) {
                result.icon = json.optString("icon", null);
            }
            return result;
        }
        return null;
    }
}
